#!/bin/bash

PROJECT=css-parsing-tests
REPO=git@github.com:SimonSapin/css-parsing-tests.git

githash=$1
if [ -z "$githash" ]; then
    echo "usage: $0 GITHASH"
    exit 1
fi

shorthash=${githash:0:8}
outputfile="${PROJECT}"-$shorthash.tar.gz

rm -rf "${PROJECT}"-temp
git clone "${REPO}" "${PROJECT}"-temp
cd "${PROJECT}"-temp
    git archive --prefix="${PROJECT}"-$shorthash/ --format=tar ${githash} \
        | gzip --stdout > ../$outputfile
cd ..
rm -rf "${PROJECT}"-temp
echo "exported source code in $outputfile"
